#include <bits/stdc++.h>

using namespace std;
using ll = long long;
const int MAXN = 1e6 + 10;
const int MOD = 998244353;

ll n;

ll f(ll a, ll b) {
    return (a*a+b*b)*(a+b);
}
int main() {
#ifdef LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif
    cin >> n;
    ll res = 1e18;
    for (ll i = 0; i*i*i <= n; i++) {
        ll l = 0, r = 1e6;
        while(l < r) {
            ll mid = l+r>>1;
            if (f(i, mid) < n) {
                l = mid+1;
            } else {
                r = mid;
            }
        }
        res = min(res, f(i, l));
    }
    cout << res << endl;
    return 0;
}